package ar.com.photo_admin.taglibs
import ar.com.photo_admin.domain.*;

class PurchaseOrderTagLib {

	def springSecurityService
	
	def isOrderCancellableDisplayed = { attrs, body ->
		PurchaseOrder order = PurchaseOrder.get(attrs.purchaseOrderId)
		if (order.isCancellable() && order.photographer == springSecurityService.getCurrentUser() ) {
			out << body()
		}
	}
	
	def isOrderRefundableDisplayed= { attrs, body ->
		PurchaseOrder order = PurchaseOrder.get(attrs.purchaseOrderId)
		if (order.isRefundable() && order.photographer == springSecurityService.getCurrentUser()) {
			out << body()
		}
	}
	
	def isOrderFinalizableDisplayed = { attrs, body ->
		PurchaseOrder order = PurchaseOrder.get(attrs.purchaseOrderId)
		if (order.isFinalizable() && order.photographer == springSecurityService.getCurrentUser()) {
			out << body()
		}
	}
}
